<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script type="text/javascript">
   for(var i=1;i<=5;i++){
       setTimeout(function(){
           console.log(i);
       },1000);//只输出一个6
       console.log(i); //1,2,3,4,5
   }
</script>
</body>
</html>